<template>
  <div v-loading="loading">

  </div>
</template>

<script>

export default {
  name: "adminLogin",
  data(){
    return {
      key: '',
      loading: false,
    }
  },
  created() {
    this.key = this.$route.query.key
    if(!this.key){
      this.$errorMessage('缺少参数')
      window.close()
      return;
    }
    this.getToken()
  },
  methods:{
    getToken(){
      this.loading = true
      this.$store.dispatch('user/backLogin', this.key).then(() => {
        this.$store.dispatch('user/getInfo');
        this.loading = false;
        this.$router.push({ path: '/' })
      }).catch((res) => {
        this.$errorMessage(res.message)
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
